home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 4 / Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso / Development / Source / MSG Demo 1.4.source Folder / Demo ƒ / Wipes ƒ / Random wipe.c < prev    next >
Text File  |  1994-04-15  |  2KB  |  76 lines

  1. /**********************************************************************\
  2.  
  3. File:        Random wipe.c
  4.  
  5. Purpose:    Graphic effect from offscreen bitmap to main window (on
  6.             screen).  See comments below for more description.
  7.  
  8. This program is free software; you can redistribute it and/or modify
  9. it under the terms of the GNU General Public License as published by
  10. the Free Software Foundation; either version 2 of the License, or
  11. (at your option) any later version.
  12.  
  13. This program is distributed in the hope that it will be useful,
  14. but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16. GNU General Public License for more details.
  17.  
  18. You should have received a copy of the GNU General Public License
  19. along with this program in a file named "GNU General Public License".
  20. If not, write to the Free Software Foundation, 675 Mass Ave,
  21. Cambridge, MA 02139, USA.
  22.  
  23. \**********************************************************************/
  24.  
  25. #include "timing.h"
  26.  
  27. #define        SUB_HOR        20
  28. #define        SUB_VER        20
  29. #define        AREA        (SUB_HOR * SUB_VER)
  30. #define CorrectTime 1
  31. #define theWindowWidth (boundsRect.right-boundsRect.left)
  32. #define theWindowHeight (boundsRect.bottom-boundsRect.top)
  33.  
  34. pascal short RandomWipe(GrafPtr sourceGrafPtr, GrafPtr destGrafPtr, Rect boundsRect);
  35.  
  36. /* Basically, we divide the window into a bunch of blocks, and copy
  37. each to the screen in random order. */
  38. pascal short RandomWipe(GrafPtr sourceGrafPtr, GrafPtr destGrafPtr, Rect boundsRect)
  39. {
  40.     int                order[AREA];
  41.     int                i;
  42.     long            randtemp;
  43.     int                ordertemp;
  44.     Rect            subBox;
  45.     Rect            dest;
  46.     Boolean            everyOther;
  47.     
  48.     everyOther=FALSE;
  49.     for(i = 0; i < AREA; i++)
  50.         order[i] = i;
  51.     
  52.     for(i = (AREA - 1); i >= 0; i--) {
  53.         randtemp = ((((long)Random()) +32767) * (i + 1)) / 65535;
  54.         
  55.         ordertemp = order[randtemp];
  56.         order[randtemp] = order[i];
  57.         order[i] = ordertemp;
  58.     }
  59.     
  60.     for(i = 0; i < AREA; i++) {
  61.         StartTiming();
  62.         subBox.top = ((order[i] / SUB_VER) * theWindowHeight) / SUB_VER;
  63.         subBox.left = ((order[i] % SUB_HOR) * theWindowWidth) / SUB_HOR;
  64.         subBox.bottom = (((order[i] / SUB_VER) + 1) * theWindowHeight) / SUB_VER;
  65.         subBox.right = (((order[i] % SUB_HOR) + 1) * theWindowWidth) / SUB_HOR;
  66.         OffsetRect(&subBox, boundsRect.left, boundsRect.top);
  67.         CopyBits(&(sourceGrafPtr->portBits), &(destGrafPtr->portBits),
  68.             &subBox, &subBox, 0, 0L);
  69.         if (everyOther)
  70.             TimeCorrection(CorrectTime);
  71.         everyOther=!everyOther;
  72.     }
  73.     
  74.     return 0;
  75. }
  76.